﻿using System;
using System.Linq.Expressions;
using Domain.Core.Specification;
using Domain.MainModule.Entities;

namespace Domain.MainModule.States
{
    public class StateNameSpecification : Specification<State>
    {
        #region public properties
        
        public string StateName
        {
            get;
            set;
        }

        #endregion

        #region constructor

        public StateNameSpecification(string stateName)
        {
            this.StateName = stateName;
        }

        #endregion

        #region public methods

        public override Expression<Func<State, bool>> SatisfiedBy()
        {
            Specification<State> spec = new TrueSpecification<State>();
            spec &= new DirectSpecification<State>(c => c.Name == this.StateName);

            return spec.SatisfiedBy();
        }

        #endregion
    }
}
